package uk.ac.durham.tel.synergynet.covanto.resource;

import java.util.Locale;
import java.util.ResourceBundle;

public class ResourceLoader {
	private static final String BUNDLE_NAME = "uk.ac.durham.tel.synergynet.covanto.resource.custom";
	private static ResourceBundle rb = null;
	
	static {
		rb = ResourceBundle.getBundle(BUNDLE_NAME, Locale.ENGLISH);
	}
	
	public static void setBundle(Locale locale) {
		try {
			rb = ResourceBundle.getBundle(BUNDLE_NAME, locale);
		} catch (Exception ex) {
			rb = ResourceBundle.getBundle(BUNDLE_NAME, Locale.ENGLISH);
		}
	}
	
	public static String getString(String key) {
		try {
			return new String(rb.getString(key).getBytes("ISO-8859-1"), "UTF-8");			
		} catch (Exception ex) {
			return key;
		}
	}
}

